package hz.mobileproject.pda.ui.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;


import java.util.List;

import hz.mobileproject.pda.R;

/**
 * Created by Lc on 2017/9/17.
 */

public class DialogListAdapter extends BaseAdapter {

    private Context mContext;
    private List<String> list;
    private LayoutInflater inflater;

    public DialogListAdapter(Context c , List<String> list){
        mContext = c;
        this.list = list;
        inflater = LayoutInflater.from(c);
    }


    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder viewHolder;
        if(convertView == null){
            convertView = LayoutInflater.from(mContext).inflate(R.layout.item_dialog_lv,null);
            viewHolder = new ViewHolder(convertView);
            convertView.setTag(viewHolder);
        }else {
            viewHolder = (ViewHolder) convertView.getTag();
        }
        viewHolder.position = position;
        viewHolder.textView.setText(list.get(position));

        return convertView;
    }

    private class ViewHolder {
        private int position;
        private TextView textView;
        public ViewHolder(View itemView) {
            textView = (TextView) itemView.findViewById(R.id.tv_inDialogLv);
        }
    }
}
